#pragma warning disable 0618
using System;
using System.Collections.Generic;
using Table.DataModel;
namespace Table.Dao
{
    public class TableFormationDao:DaoBase<TableFormation>
    {
        public override string GetFileName()
        {
            return "TableFormation.csv";
        }
        public override void BuildIndex()
        {
            if (cacheList != null)
            {
                cachePrimaryInt = new Dictionary<int, TableFormation>(cacheList.Count);
            }
            base.BuildIndex();
        }
        public override void AddPrimaryIndex(TableFormation model)
        {
            #if UNITY_EDITOR
            if(cachePrimaryInt.ContainsKey(model.formationId)) UnityEngine.Debug.LogError("数据表id重复:TableFormation->id: " + model.formationId);
            #endif
            cachePrimaryInt[model.formationId] = model;
        }
        protected override TableFormation ParseRowData(string[] rowData)
        {
            TableFormation data = new TableFormation();
            if (!string.IsNullOrEmpty(rowData[0]))
            {
                data.formationId = int.Parse(rowData[0]);
            }
            if (!string.IsNullOrEmpty(rowData[1]))
            {
                data.formationName = rowData[1];
            }
            if (!string.IsNullOrEmpty(rowData[2]))
            {
                data.openLevel = int.Parse(rowData[2]);
            }
            if (!string.IsNullOrEmpty(rowData[3]))
            {
                data.effectLevel = int.Parse(rowData[3]);
            }
            if (!string.IsNullOrEmpty(rowData[4]))
            {
                data.propAdd = rowData[4];
            }
            if (!string.IsNullOrEmpty(rowData[5]))
            {
                data.defualtOpen = int.Parse(rowData[5]);
            }
            if (!string.IsNullOrEmpty(rowData[6]))
            {
                data.openCost = rowData[6];
            }
            if (!string.IsNullOrEmpty(rowData[7]))
            {
                data.desc = rowData[7];
            }
            if (!string.IsNullOrEmpty(rowData[8]))
            {
                data.extraFightPower = int.Parse(rowData[8]);
            }
            if (!string.IsNullOrEmpty(rowData[9]))
            {
                data.FormationQuality = int.Parse(rowData[9]);
            }
            return data;
        }
    }
}
